//
//  JDDetailAPI.swift
//  LeGou
//
//  Created by 刘亿前 on 2022/9/19.
//

import Foundation

enum JDDetailAPI {
    // banner
    case jd_banner
    // 分类
    case jd_cate
    // 商品列表
    case jd_list(_ param: [String: Any])
    // 商品详情
    case jd_detail(_ param: [String: Any])
    // 商品详情猜你喜欢
    case jd_detail_like(_ param: [String: Any])
    // 转链
    case jd_link(_ param: [String: Any])
}

extension JDDetailAPI: ZMApiProvider {
    func BaseUrl() -> String {
        return baseUrl
    }
    
    func urlAndMthodAndParam() -> (url: String, method: ZMHTTPMethod, params: [String : Any], body: Bool) {
        switch self {
        case .jd_banner:
            return ("/api/front/banner/orderList", .get, ["type":"5"], false)
        case .jd_cate:
            return ("/api/front/jd/jdCategoryList", .get, [:], false)
        case .jd_list(let pa):
            return ("/api/front/jd/jdSavesMoney", .get, pa, false)
        case .jd_detail(let pa):
            return ("/api/front/jd/jdGoodsDetails", .get, pa, false)
        case .jd_detail_like(let pa):
            return ("/api/front/jd/guessYouLikeIt", .get, pa, false)
        case .jd_link(let pa):
            return ("/api/front/jd/getPrivilegeLink", .post, pa, true)
        }
    }
    
    func HTTPHeader() -> ZMHTTPHeaders? {
        return AppHelper.reqeustHeader()
    }
    
    func UpLoadData() -> [Data]? {
        return nil
    }
    
    func singleRequest() -> Bool {
        switch self {
//            case .power_order_list:
//                return true
            default:
                return false
        }
    }
}

